package com.example.demo.service.impl;


import com.example.demo.Mapper.DeptMapper;
import com.example.demo.dao.impl.DeptDaoImpl;
import com.example.demo.pojo.Dept;
import com.example.demo.pojo.Result;
import com.example.demo.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class addDeptServiceImpl implements DeptService {
    @Autowired
    DeptDaoImpl deptDao;
    @Autowired
    DeptMapper deptMapper;

    @Override
    public String addDeptService(String ask) {
        if(ask.equals("用户来请求啦"))
        {
            //访问数据访问层
            String result = deptDao.addDeptDao("请添加数据!");
            return result;

        }
        return "业务请求失败！";
    }


    public List<Dept> selectAllService()
    {
        return deptMapper.selectAllDao();
    }
    public Result deleteAllService( Integer id){
        deptMapper.deleteAllDao(id);
        return Result.success();
    }
    public void addService(Dept dept){
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }


}
